package edu.umd.ion.wavemeter.server;

public class RawChannelData {
	public boolean ChannelActive = false;
	private int ActiveVirtChannel = -1;
	public int LastVirtChannel = -1;
	boolean LockedChannel = false;
	public int idx_begin = 0;
	public int idx_end = 0;
	public int idx_current = 0;
	
	public int activeVirtChannel() {
		return ActiveVirtChannel;
	}
	
	public void setActiveVirtChannel(int channel) {
		LastVirtChannel = ActiveVirtChannel<0 ? channel : ActiveVirtChannel;
		ActiveVirtChannel = channel;
	}
	
	public void setPointers(int begin, int end, boolean locked) {
		idx_begin = begin;
		idx_end = end;
		idx_current = begin;
		LockedChannel = locked;
	}
	
	int nextChannelIndex() throws ChannelNothingToDo {
		if (idx_begin==idx_end) throw new ChannelNothingToDo();
		int current = idx_current;
		if (++idx_current==idx_end) { idx_current=idx_begin; }
		return current;
	}
	
	int currentChannelIndex() throws ChannelNothingToDo {
		if (idx_begin==idx_end) throw new ChannelNothingToDo();
		return idx_current;
	}
}
